<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Controller
 *
 * @author Marek S
 */
abstract class Controller {
    protected $result;
    protected $view;
    
    abstract protected function convertViewToResult();
    abstract public function getResult();
    
    
    protected function preExecute(){
        
    }
    
    protected function postExecute(){
        
    }
    
    public function __construct() {
        $this->view = new View();
    }
    
    public function __set($name, $value) {
        $this->view->addVar($name, $value);
    }
    
    public function __get($name) {
        $this->view->getVar($name);
    }
    
    public function executeAction($name){
        $this->preExecute();
        $this->$name();
        $this->postExecute();
    }
}
